<template>
    <div>
        <table border="1">
            <tr>
                <td>名称</td>
                <td>设备类型</td>
                <td>描述</td>
                <td>创建时间</td>
                <td>操作</td>
            </tr>
            <tr v-for="(i,index) in goodslist">
                <td>{{i.name}}</td>
                <td>MOT_U202</td>
                <td>{{i.sign}}</td>
                <td>{{i.create_time}}</td>
                <td>
                    <Button @click="del(i.id)" color="red">删除</Button>
                </td>
            </tr>
        </table>
        <button @click="init(i)" v-for="i in page_range">{{i}}</button>
    </div>
</template>

<script>
import { genrelist_post,genredelete_post } from './axios_api/api';
export default {
  
    data:function(){
        return{
            goodslist:[],
            page_range:''
        }
    },

    methods:{
        init:function(i){

            var data = {i:i}
            genrelist_post(data).then((res)=>{
                if (res.code==200)
                {
                    this.goodslist = res.goodslist;
                    this.page_range = res.page_range
                }
            })
        },
        del(id){
            var data = {id:id}
            genredelete_post(data).then((res)=>{
                if(res.code==200)
                {
                    alert('删除成功');
                    location.reload();
                }else{
                    alert('删除出错，请稍后再试')
                }
            })
        }
    },


    mounted(){
        this.init();
    }
}
</script>